package top.xunfong.knowledge.controller;

import top.xunfong.common.core.domain.R;
import top.xunfong.domain.dto.OrderGrabbingDTO;
import top.xunfong.domain.dto.ResetFlashSaleDTO;
import top.xunfong.knowledge.service.FlashSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/flash-sale")
public class FlashSaleController {

    @Autowired
    private FlashSaleService flashSaleService;


    /**
     * 重置秒杀数据
     *
     * @param dto
     * @return
     */
    @PostMapping("/reest")
    public R<String> reset(@RequestBody ResetFlashSaleDTO dto) {
        flashSaleService.reset(dto);
        return R.ok();
    }

    @PostMapping("/order-grabbing")
    public R<String> orderGrabbing(@RequestBody OrderGrabbingDTO dto) {
        flashSaleService.orderGrabbing(dto);
        return R.ok();
    }

}
